package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.OrderConfig;
import com.micro.modual.extension.OrderConfigExtension;
import com.micro.modual.mapper.OrderConfigMapper;
import com.micro.modual.model.bo.orderconfig.OrderConfigBO;
import com.micro.modual.service.OrderConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>订单配置表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("orderConfigService")
public class OrderConfigServiceImpl extends AbstractBasicsServiceImpl<OrderConfig,Long> implements OrderConfigService {

    @Autowired
    private OrderConfigMapper orderConfigMapper;

    /**
     * <h2>新增订单配置表详情</h2>
     * @param orderConfigBO {@link OrderConfigBO} 订单配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addOrderConfig(OrderConfigBO orderConfigBO) {
        OrderConfig orderConfig = OrderConfigExtension.converAddOrderConfig(orderConfigBO);
        orderConfigMapper.insertSelective(orderConfig);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改订单配置表详情</h2>
     * @param orderConfigBO  {@link OrderConfigBO} 订单配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editOrderConfig(OrderConfigBO orderConfigBO) {
        OrderConfig orderConfig = OrderConfigExtension.converEditOrderConfig(orderConfigBO);
        orderConfigMapper.updateByPrimaryKeySelective(orderConfig);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除订单配置表信息</h2>
     * @param id  订单配置表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteOrderConfig(Long id) {
        orderConfigMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
